package com.fone.player.view;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.fone.player.R;
import com.fone.player.activity.personal.UserInfoActivity;
import com.fone.player.util.ScreenUtil;

public class ChangeHeadImageDialog implements OnClickListener {

	private Button changeSureBtn, changeCancelBtn, takePhotoBt,
			chooseFromAlbumBt;
	private CustomDialog dialog;
	private Context mContext;
	private Handler mHandler;

	public ChangeHeadImageDialog(Context mContext, UserInfoActivity activity,Handler mHandler) {

		this.mContext = mContext;
		this.mHandler = mHandler;

		View changeHeadIconView = LayoutInflater.from(mContext).inflate(
				R.layout.personal_change_head_icon_dialog, null);
		dialog = new CustomDialog((Context) activity, changeHeadIconView);
		dialog.show();

		changeHeadIconView.setMinimumWidth((int) (ScreenUtil
				.getScreenWidthPix(mContext) * 0.8));// 设置dialog的宽度

		takePhotoBt = (Button) changeHeadIconView
				.findViewById(R.id.dialog_take_photo_bt);
		chooseFromAlbumBt = (Button) changeHeadIconView
				.findViewById(R.id.dialog_choose_from_album_bt);
		changeSureBtn = (Button) changeHeadIconView
				.findViewById(R.id.change_name_sure_id);
		changeCancelBtn = (Button) changeHeadIconView
				.findViewById(R.id.change_name_cancel_id);

		takePhotoBt.setOnClickListener(this);
		chooseFromAlbumBt.setOnClickListener(this);
		changeSureBtn.setOnClickListener(this);
		changeCancelBtn.setOnClickListener(this);

	}

	@Override
	public void onClick(View v) {
		Message msg = new Message();
		switch (v.getId()) {
		case R.id.dialog_take_photo_bt:
			// 拍照
			Toast.makeText(mContext, "点击拍照", Toast.LENGTH_SHORT).show();
			msg.what = UserInfoActivity.REQUEST_CAMERA;
			mHandler.sendMessage(msg);
			dialog.cancel();
			break;
		case R.id.dialog_choose_from_album_bt:
			// 从相册选择
			Toast.makeText(mContext, "跳转相册选择", Toast.LENGTH_SHORT).show();
			msg.what = UserInfoActivity.REQUEST_GALLERY;
			mHandler.sendMessage(msg);
			dialog.cancel();
			break;
		case R.id.change_name_sure_id:
			// 确定按钮
			break;
		case R.id.change_name_cancel_id:
			// 取消按钮
			dialog.cancel();
			break;

		default:
			break;
		}

	}
}
